#!/bin/bash
#Color
green="\033[32m"
reset="\033[0m"
yellow="\033[33m"

home_dir=$(pwd)

if [ -d "lib" ]; then
	echo -e "${yellow}[*]${reset} Exist dir lib"
else
	mkdir lib
	echo -e "${green}[+]${reset} Create dir lib"
fi

#Install args
if [ -d "$home_dir/lib/args" ]; then
	echo -e "${yellow}[*]${reset} Exist lib args"
else
	cd lib
	git clone https://github.com/Taywee/args
	cd args
	echo -e "${yellow}[!]${reset} Enter root password on 'sudo make install'"
	sudo make install
	cd $home_dir
	echo -e "${green}[+]${reset} Installing lib args on C++"
fi

#Install thread-pool
if [ -d "$home_dir/src/thread-pool" ]; then
	echo -e "${yellow}[*]${reset} Exist lib thread-pool"
else
	cd lib
	git clone https://github.com/bshoshany/thread-pool
	cd $home_dir
	echo -e "${green}[+]${reset} Installing lib thread-pool on C++"
fi

#Installing Nuclei
if command -v nuclei; then
	echo -e "${yellow}[*]${reset} Already installed nuclei"
else
	cd $home_dir
	git clone https://github.com/projectdiscovery/nuclei.git
	cd nuclei/cmd/nuclei
	if command -v go; then
		echo -e "${green}[+]${reset} Go is installed"
	else
		echo -e "${red}[-]${reset} Go is not installed"
		echo -e "${yellow}[!]${reset} Go is required to build nuclei. Please install Go"
		echo -e "${yellow}[!]${reset} Visit the site https://go.dev/doc/install"
		exit 1
	fi
	go build
	echo -e "${yellow}[!]${reset} Enter root password on 'sudo mv nuclei /usr/local/bin/'"
	sudo mv nuclei /usr/local/bin/
	cd $home_dir
	echo -e "${green}[+]${reset} Installing Nuclei"
fi

if [ -d "$home_dir/plugins_nuclei" ]; then
	echo -e "${yellow}[*]${reset} Exist dir plugins_nuclei"
else
	mkdir plugins_nuclei
	echo -e "${yellow}[+]${reset} Create dir plugins_nuclei"
fi
cd $home_dir/plugins_nuclei

#Install honeypots-detection plugins
if [ -d "$home_dir/plugins_nuclei/honeypots-detection" ]; then
	echo -e "${yellow}[*]${reset} Already installed honeypots-detection"
else
	git clone https://github.com/UnaPibaGeek/honeypots-detection.git
	echo -e "${green}[+]${reset} Installing honeypots-detection"
fi
exit 0
